package com.ruoyi.carUserService.service.impl;

import com.ruoyi.carUserService.mapper.LoginUserMapper;
import com.ruoyi.carUserService.service.LoginUserService;
import com.ruoyi.system.api.domain.CarUser;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
public class LoginUserServiceImpl implements LoginUserService {

    @Autowired
    private LoginUserMapper loginUserMapper;

    @Override
    public Integer LoginUser(String phone) {
        Integer userByPhone = loginUserMapper.findUserByPhone(phone);
        if(userByPhone != null){
            return userByPhone;
        }else {
            CarUser carUser = new CarUser();
            carUser.setUserPhone(phone);
            carUser.setUserName("默认昵称");
            carUser.setUserAvatar("beijing.aliyuncs.com/a63e573bbdfe43c399e367c31653104fPtdqFvvSjlsu429c596fb32307870f609da50c0be385.jpg");
            carUser.setUserStatus(0L);
            carUser.setUserDeleted(0L);
            Integer userId = loginUserMapper.addUser(carUser);
            return userId.intValue();
        }
    }
}
